/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package module1;
import java.beans.PropertyVetoException;
//import java.util.logging.Level;
//import java.util.logging.Logger;
import javax.swing.*;
import net.sf.jasperreports.engine.JRException;
import report.SubReport;
/**
 *
 * @author OSIRIS
 */
public class MainFrame extends javax.swing.JFrame {

    /**
     * Creates new form MainFrame
     */
    private JInternalFrame frm=null;
    public MainFrame() {
        initComponents();
    }
    public void close(){
        if(frm!=null){
            frm.dispose();
        }
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        menuBar1 = new java.awt.MenuBar();
        menu1 = new java.awt.Menu();
        menu2 = new java.awt.Menu();
        menuBar2 = new java.awt.MenuBar();
        menu3 = new java.awt.Menu();
        menu4 = new java.awt.Menu();
        popupMenu1 = new java.awt.PopupMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuBar2 = new javax.swing.JMenuBar();
        jMenu4 = new javax.swing.JMenu();
        jMenu5 = new javax.swing.JMenu();
        desktopPane = new javax.swing.JDesktopPane();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuDsDanhMuc = new javax.swing.JMenuItem();
        jMenuDsSanPham = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuTimKiem = new javax.swing.JMenuItem();
        jMenu6 = new javax.swing.JMenu();
        jMenuDsKhachHang = new javax.swing.JMenuItem();
        jMenuQuiDinh = new javax.swing.JMenu();
        jMenuDsQuiDinh = new javax.swing.JMenuItem();
        jMenuHoaDon = new javax.swing.JMenu();
        jMenuLapHoaDon = new javax.swing.JMenuItem();
        jMenuDanhSachHoaDon = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuReportSanPham = new javax.swing.JMenuItem();
        jMenuReportNhapHang = new javax.swing.JMenuItem();

        menu1.setLabel("File");
        menuBar1.add(menu1);

        menu2.setLabel("Edit");
        menuBar1.add(menu2);

        menu3.setLabel("File");
        menuBar2.add(menu3);

        menu4.setLabel("Edit");
        menuBar2.add(menu4);

        popupMenu1.setLabel("popupMenu1");

        jMenuItem1.setText("jMenuItem1");

        jMenu4.setText("File");
        jMenuBar2.add(jMenu4);

        jMenu5.setText("Edit");
        jMenuBar2.add(jMenu5);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Cua Hang Quan Ao");

        desktopPane.setBackground(new java.awt.Color(204, 204, 204));
        desktopPane.setMaximumSize(new java.awt.Dimension(500, 400));
        desktopPane.setPreferredSize(new java.awt.Dimension(1000, 600));
        getContentPane().add(desktopPane, java.awt.BorderLayout.CENTER);

        jMenu1.setText("Sản Phẩm");

        jMenuDsDanhMuc.setText("Danh Sách Danh Mục");
        jMenuDsDanhMuc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuDsDanhMucActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuDsDanhMuc);

        jMenuDsSanPham.setText("Danh Sách Sản Phẩm");
        jMenuDsSanPham.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuDsSanPhamActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuDsSanPham);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Công cụ");
        jMenu2.setActionCommand("");

        jMenuTimKiem.setText("Tìm Kiếm Nâng Cao");
        jMenuTimKiem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuTimKiemActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuTimKiem);

        jMenuBar1.add(jMenu2);

        jMenu6.setText("Khách Hàng");

        jMenuDsKhachHang.setText("Danh Sách Khách Hàng");
        jMenuDsKhachHang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuDsKhachHangActionPerformed(evt);
            }
        });
        jMenu6.add(jMenuDsKhachHang);

        jMenuBar1.add(jMenu6);

        jMenuQuiDinh.setText("Qui Định");

        jMenuDsQuiDinh.setText("Danh Sach Qui Dinh");
        jMenuDsQuiDinh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuDsQuiDinhActionPerformed(evt);
            }
        });
        jMenuQuiDinh.add(jMenuDsQuiDinh);

        jMenuBar1.add(jMenuQuiDinh);

        jMenuHoaDon.setText("Hóa Đơn");

        jMenuLapHoaDon.setText("Lập Hóa Đơn");
        jMenuLapHoaDon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuLapHoaDonActionPerformed(evt);
            }
        });
        jMenuHoaDon.add(jMenuLapHoaDon);

        jMenuDanhSachHoaDon.setText("Danh Sách Hóa Đơn");
        jMenuDanhSachHoaDon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuDanhSachHoaDonActionPerformed(evt);
            }
        });
        jMenuHoaDon.add(jMenuDanhSachHoaDon);

        jMenuBar1.add(jMenuHoaDon);

        jMenu3.setText("Report");

        jMenuReportSanPham.setText("Sản Phẩm");
        jMenuReportSanPham.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuReportSanPhamActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuReportSanPham);

        jMenuReportNhapHang.setText("Nhập Hàng");
        jMenuReportNhapHang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuReportNhapHangActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuReportNhapHang);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuDsDanhMucActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuDsDanhMucActionPerformed

        // TODO add your handling code here:
        close();
        frm=new DanhMucFrame();
        frm.setVisible(true);
        this.desktopPane.add(frm);
    }//GEN-LAST:event_jMenuDsDanhMucActionPerformed

    private void jMenuDsSanPhamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuDsSanPhamActionPerformed
        // TODO add your handling code here:
        close(); 
        frm=new SanPhamFrame();
        frm.setVisible(true);
        this.desktopPane.add(frm);
    }//GEN-LAST:event_jMenuDsSanPhamActionPerformed

    private void jMenuTimKiemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuTimKiemActionPerformed
        // TODO add your handling code here:close(); 
         close(); 
        frm=new TimKiemFrame();
        frm.setVisible(true);
        this.desktopPane.add(frm);
    }//GEN-LAST:event_jMenuTimKiemActionPerformed

    private void jMenuDsQuiDinhActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuDsQuiDinhActionPerformed
        // TODO add your handling code here:
        close(); 
        frm=new QuiDinhFrame();
        frm.setVisible(true);
        this.desktopPane.add(frm);
    }//GEN-LAST:event_jMenuDsQuiDinhActionPerformed

    private void jMenuReportNhapHangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuReportNhapHangActionPerformed
        // TODO add your handling code here:
         try {
               close();
            frm = new SubReport("report/NhapHang.jasper");
            frm.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight());
            frm.setVisible(true);
            desktopPane.add(frm);
            frm.setSelected(true);
        } catch (JRException ex) {
           // Logger.getLogger(MainReport.class.getName()).log(Level.SEVERE, null, ex);
            
        } catch (PropertyVetoException pve) {
            pve.printStackTrace();
        }
    }//GEN-LAST:event_jMenuReportNhapHangActionPerformed

    private void jMenuReportSanPhamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuReportSanPhamActionPerformed
        // TODO add your handling code here:
         try {
               close();
            frm = new SubReport("report/SanPham.jasper");
            frm.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight());
            frm.setVisible(true);
            desktopPane.add(frm);
            frm.setSelected(true);
        } catch (JRException ex) {
           // Logger.getLogger(MainReport.class.getName()).log(Level.SEVERE, null, ex);
            
        } catch (PropertyVetoException pve) {
            pve.printStackTrace();
        }
    }//GEN-LAST:event_jMenuReportSanPhamActionPerformed

    private void jMenuDsKhachHangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuDsKhachHangActionPerformed
        // TODO add your handling code here:
         close(); 
           LapHoaDonFrame lhdFr=new LapHoaDonFrame();
        frm=new KhachHangFrame(lhdFr,"menu");
        frm.setVisible(true);
        this.desktopPane.add(frm);
    }//GEN-LAST:event_jMenuDsKhachHangActionPerformed

    private void jMenuLapHoaDonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuLapHoaDonActionPerformed
        // TODO add your handling code here:
         close(); 
        frm=new LapHoaDonFrame();
        frm.setVisible(true);
        this.desktopPane.add(frm);
    }//GEN-LAST:event_jMenuLapHoaDonActionPerformed

    private void jMenuDanhSachHoaDonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuDanhSachHoaDonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuDanhSachHoaDonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane desktopPane;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenu jMenu6;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuBar jMenuBar2;
    private javax.swing.JMenuItem jMenuDanhSachHoaDon;
    private javax.swing.JMenuItem jMenuDsDanhMuc;
    private javax.swing.JMenuItem jMenuDsKhachHang;
    private javax.swing.JMenuItem jMenuDsQuiDinh;
    private javax.swing.JMenuItem jMenuDsSanPham;
    private javax.swing.JMenu jMenuHoaDon;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuLapHoaDon;
    private javax.swing.JMenu jMenuQuiDinh;
    private javax.swing.JMenuItem jMenuReportNhapHang;
    private javax.swing.JMenuItem jMenuReportSanPham;
    private javax.swing.JMenuItem jMenuTimKiem;
    private java.awt.Menu menu1;
    private java.awt.Menu menu2;
    private java.awt.Menu menu3;
    private java.awt.Menu menu4;
    private java.awt.MenuBar menuBar1;
    private java.awt.MenuBar menuBar2;
    private java.awt.PopupMenu popupMenu1;
    // End of variables declaration//GEN-END:variables
}
